package com.xuelang.pipeline.artifact.app.nexus3v1;

import com.xuelang.pipeline.artifact.app.nexus3v1.config.Nexus3v1RestFeignConfig;
import com.xuelang.pipeline.artifact.app.nexus3v1.fallback.SecurityUserServiceFallbackFactory;
import com.xuelang.pipeline.artifact.app.nexus3v1.request.CreateUserRequest;
import com.xuelang.pipeline.artifact.app.nexus3v1.response.CreateUserResponse;
import com.xuelang.pipeline.artifact.app.nexus3v1.xo.ApiResponseXO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import jakarta.validation.Valid;

/**
 * 封装NexusOSS 3.37.3-02以上安全-用户相关接口-对应Security management: users
 *
 * @author xiwen.zxg
 * @since 2024/7/9
 */
@FeignClient(
        name = "security-user-service",
        url = "${feign.rpc.nexus3V1RestService}",
        configuration = Nexus3v1RestFeignConfig.class,
        fallbackFactory = SecurityUserServiceFallbackFactory.class)
public interface SecurityUserService {


    /**
     * 创建用户
     *
     * @param createUserRequest
     * @return
     */
    @PostMapping(value = "/v1/security/users", produces = "application/json;charset=utf-8")
    ApiResponseXO<CreateUserResponse> createUser(@RequestBody @Valid CreateUserRequest createUserRequest);

    /**
     * 删除用户
     *
     * @param userId
     * @return
     */
    @DeleteMapping(value = "/v1/security/users/{userId}", produces = "application/json;charset=utf-8")
    ApiResponseXO<Void> deleteUser(@PathVariable("userId") String userId);

}
